<template>
    <el-main>
        <el-main class="ep-body">
            <epl-top-bar :datas="{formData:form}" showPerson psTagType="PERSON_PENSION_QUERY"
                         personType="PERSON_ALL_EXACT">
            </epl-top-bar>
            <epl-userMessage dataType="person" idCount="8">
                <template slot-scope="scope">
                    <epl-userMessageItem title="当前待遇" :sum="123">
                        <epl-column label="扣发总月数" :value="form.bac062.value"></epl-column>
                        <epl-column label="扣发总金额" :value="'  ￥'+form.bac063.value"></epl-column>
                        <!--<epl-column label="当期实发金额" :value="'￥'+((+form.bac063.value)+(+form.sum.value))"></epl-column>-->
                    </epl-userMessageItem>
                </template>
            </epl-userMessage>
            <el-card class="ep-card">
                <ep-title>请输入精减人员待遇暂停信息</ep-title>
                <el-form :model="form" ref="form" :rules="rules">
                    <el-row :gutter="10">
                        <ep-select colspan="8"  label="变更类型" name="bglx" placeholder="请选择变更类型" :property="form.bglx" codetype="BGLX"
                        p="R"  rules="this.$rules.test_noBlank" :datas="{formData:form}" ></ep-select>
                        <ep-select colspan="8"  label="变更原因" name="aae160" placeholder="请选择变更原因" :property="form.aae160" codetype="AAE160"
                                   p="R"  rules="this.$rules.test_noBlank" :datas="{formData:form}" ></ep-select>
                        <ep-date colspan="8" label="停发日期" name="aae041" :property="form.aae041" isChange rules="this.$rules.test_noBlank"
                                 placeholder="请选择停发日期" p="R" format="yyyyMM"
                                 :datas="{formData: form,panel:panel}"></ep-date>
                    </el-row>
                    <el-row :gutter="10">
                        <ep-input colspan="8" label="扣发开始年月"  name="bac061"  :property="form.bac061" p="D"
                                  :datas="{formData:form}" ></ep-input>
                        <ep-input colspan="8" label="扣发总月数"  name="bac062"  :property="form.bac062" p="D"
                                  :datas="{formData:form}"></ep-input>
                        <ep-input colspan="8" label="扣发总金额"  name="bac063"  :property="form.bac063" p="D"
                                  :datas="{formData:form}"></ep-input>
                    </el-row>
                    <el-row :gutter="10">
                        <ep-textarea :rows="4" colspan="24" label="备注" name="aae013" :property="form.aae013"
                                     placeholder="请输入备注" p="E" :datas="{formData:form}"></ep-textarea>
                    </el-row>
                    <el-row type="flex" justify="center">
                        <ep-saveButton id="doSave" type="primary" top="20" bottom="20" ref="save" @formValidate="formValidate"
                                       :validate="['form']"
                                       :datas="{formData: form,panel:panel}"></ep-saveButton>
                    </el-row>
                </el-form>
                <el-tabs v-model="activeName2" type="card">
                    <el-tab-pane label="精减人员待遇扣发明细" name="1">
                        <ep-table :data="tableData2" :pager="20">
                            <ep-table-column editor="text" name="bklb" header="补扣类别"></ep-table-column>
                            <ep-table-column editor="text" name="eae003" header="待遇类别"></ep-table-column>
                            <ep-table-column editor="text" name="aae041" header="开始年月"></ep-table-column>
                            <ep-table-column editor="text" name="aae042" header="终止年月"></ep-table-column>
                            <ep-table-column editor="text" name="aae002" header="对应业务期"></ep-table-column>
                            <ep-table-column editor="text" name="aae019" header="扣发金额"></ep-table-column>
                        </ep-table>
                    </el-tab-pane>
                    <el-tab-pane label="历史发放情况" name="2">
                        <ep-table :data="tableData3" :pager="20" rowDbClick>
                            <ep-table-column editor="text" header="业务期" name="aae002"></ep-table-column>
                            <ep-table-column editor="text" header="对应业务期" name="aae002s"></ep-table-column>
                            <ep-table-column editor="text" header="统筹内支付金额" name="tcnmoney"></ep-table-column>
                            <ep-table-column editor="text" header="统筹外支付金额" name="tcwmoney"></ep-table-column>
                            <ep-table-column editor="text" header="养老待遇支付合计" name="totalmoney"></ep-table-column>
                        </ep-table>
                    </el-tab-pane>
                </el-tabs>
            </el-card>
        </el-main>
    </el-main>
</template>
<script type="es6">
    export default {
        data() {
            return {
                form:{
                    bglx: {
                        key: '',
                        value: '',
                        p: 'R'
                    },
                    aae160: {
                        key: '',
                        value: '',
                        p: 'R'
                    },
                    aae041: {
                        value: '',
                        p: 'R'
                    },
                    bac061: {
                        value: '',
                        p: 'D'
                    },
                    bac062: {
                        value: '',
                        p: 'D'
                    },
                    bac063: {
                        value: '',
                        p: 'D'
                    },
                    aae013: {
                        value: '',
                        p: 'E'
                    },

                },
                activeName2: '1',
                tableData2: {},
                tableData3: {},
                panel: {},

                rules:{
                    bglx: [
                        {required: true ,validator: this.$rules.test_noBlank, trigger: 'blur'}

                    ],
                    aae160: [
                        {required: true ,validator: this.$rules.test_noBlank, trigger: 'blur'}

                    ],
                    aae041: [
                        {required: true ,validator: this.$rules.test_noBlank, trigger: 'blur'}
                    ],
                },
                codeTypes:{
                    BGLX:[],
                    AAE160:[],

                },
                codeTypeFilters:{

                },
                pager: {
                    page: 1,
                    size: 10
                },
                total: 0,
            }
        },
        computed: {
            functionId() {
                if (this.$store.getters.init.path !== this.$route.path) return;
                if (this.$store.getters.init.mdParam === null || this.$store.getters.init.mdParam === undefined) return;
                if (this.$store.getters.init.mdParam.functionid === undefined) return;
                return this.$store.getters.init.mdParam.functionid;
            },
            backFun() {
                return this.$store.getters.backFun;
            },
            init_formData() {
                if (this.$store.getters.init.path !== this.$route.path)  return;
                return this.$store.getters.init.form;
            },
            doInitformData: {
                get: function () {
                    if (this.$store.getters.common === null) return [];
                    if (this.$store.getters.common.path !== this.$route.path) return;
                    return this.$store.getters.common.formData;
                },
                set: function (newValue) {
                    if (newValue.path !== this.$route.path) return;
                    return newValue;
                }
            },
            init_panel() {
                if (this.$store.getters.init.path !== this.$route.path)  return;
                return this.$store.getters.init.panel;
            },
            doInitpanel: {
                get: function () {
                    if (this.$store.getters.common === null) return [];
                    if (this.$store.getters.common.path !== this.$route.path) return;
                    return this.$store.getters.common.panel;
                },
                set: function (newValue) {
                    if (newValue.path !== this.$route.path) return;
                    return newValue;
                }
            },

        },
        created() {
            let param = {
                path: this.$route.path,
                codeTypes:this.codeTypes,
                codeTypeFilters: window.btoa(JSON.stringify(this.codeTypeFilters)),
                form:this.form,
                tableData2:this.tableData2,
                tableData3:this.tableData3,
                panel:this.panel

            };
            this.$store.dispatch('SET_INIT', param);
        },
        watch: {
            init_formData: {
                handler(value) {
                    if (value == undefined) return;
                    this.getformData(value);
                },
                deep: true
            },
            doInitformData: {
                handler(value) {
                    if (value == undefined) return;
                    this.getformData(value);
                },
                deep: true
            },
            init_panel: {
                handler(value) {
                    if (value == undefined) return;
                    this.getpanel(value);
                },
                deep: true
            },
            doInitpanel: {
                handler(value) {
                    if (value == undefined) return;
                    this.getpanel(value);
                },
                deep: true
            },

            backFun: {
                handler(value) {
                    if (value === null) return;
                    this.customBackFun();
                    let backFun = [];
                    backFun = value.split(',');
                    if (backFun.indexOf('rDoInit') >= 0) {
                        let codeTypes = {
                            BGLX:[],
                            AAE160:[],

                        };
                        let form = {
                            bglx: {
                                key: '',
                                value: '',
                                p: 'R'
                            },
                            aae160: {
                                key: '',
                                value: '',
                                p: 'R'
                            },
                            aae041: {
                                value: '',
                                p: 'R'
                            },
                            bac061: {
                                value: '',
                                p: 'D'
                            },
                            bac062: {
                                value: '',
                                p: 'D'
                            },
                            bac063: {
                                value: '',
                                p: 'D'
                            },
                            aae013: {
                                value: '',
                                p: 'E'
                            },

                        };
                        let tableData2= {};
                        let tableData3= {};
                        let panel= {};

                        let param = {
                            path: this.$route.path,
                            codeTypes:codeTypes,
                            codeTypeFilters: window.btoa(JSON.stringify(this.codeTypeFilters)),
                            form:form,
                            tableData2:tableData2,
                            tableData3:tableData3,
                            panel:panel

                        };
                        this.$store.dispatch('SET_INIT', param);
                    }
                }
            }
        },
        methods: {
            getformData(value) {
                this.form = value;
            },
            getpanel(value) {
                this.panel = value;
            },

            handleSizeChange(val) {
                console.log(`每页 ${val} 条`);
            },
            handleCurrentChange(val) {
                console.log(`当前页: ${val}`);
            },
            handleEdit(id) {
                this.dialogFormVisible = true;
            },
            formValidate(value){
                if(value && value.length>0){
                    value.map((item,index)=>{
                        this.$refs[value].validate((valid) => {
                            if (valid) {
                                if(index+1 == value.length){
                                    this.$refs.save.btn();
                                }
                            } else {
                                return false;
                            }
                        });
                    })
                }
            },

            customBackFun(){//自定义方法体
            },
        },
    }
</script>
